﻿@inherits System.Web.Mvc.WebViewPage<MVCSample.UI.Models.NewsSearchModel>

<h2>@Model.Title</h2>
Search text: <input type="text" id="SearchText" />
Start with: <input type="text" id="StartWith" />
<a href="#" id="Search" style="text-decoration:none"><img src='@Url.Content("~/Content/Images/Search.jpg")' width="30px" height="20px" border="0">Search</img></a>
<ul>
@foreach(var news in Model.ListOfNews) {

	var clusterUrl = string.Empty;
	if(news.ClusterUrl != "") {
		clusterUrl = news.ClusterUrl;
	}

	var imgUrl = string.Empty;
	if(news.Image != null && news.Image.Url != "") {
		imgUrl = news.Image.Url;
	}

	<li><b>GsearchResultClass:</b> @news.GsearchResultClass</li>	
	<li><b>Content:</b> @news.Content</li>
	<li><b>Language:</b> @news.Language</li>
	<li><b>Location:</b> @news.Location</li>
	<li><b>PublishedDate:</b> @news.PublishedDate</li>
	<li><b>Publisher:</b> @news.Publisher</li>
	
	<a href="@clusterUrl"><img src="@imgUrl"></img></a>
	<li>
		Related Story:
		<table>
			<tr style="background-color:#0000FF; color: #fff	">
				<td>Title</td><td>Publisher</td><td>Date</td>
			</tr>
			@foreach(var story in news.Stories) {
				<tr>
					<td>@story.PublishedDate</td>
					<td>@story.Publisher</td>					
					<td>@story.Title</td>										
				</tr>
			}
		</table>
	</li>
}
</ul>

<script language="javascript" type="text/javascript">
	var searchUrl = '@VirtualPathUtility.ToAbsolute("~/Home/News")';

	$(document).ready(function () {		
		$('#Search').click(function () {			
			var searchText = $('#SearchText').val();
			var startWith = $('#StartWith').val();

			var callAjax = new CallAjax(searchText, startWith, searchUrl);
			callAjax.search();			
		});
	});
</script>